/**
 * @created June 7, 2004
 * 
 * @modified March 7, 2007
 * @author adelaye
 * @author jprieur
 *
 */
package kernel;

public class DataObstacle extends DataType
{
    private String _name;

    private double _alpha;
    public final static double ALPHA_DEF = 0.0;
    public final static double ALPHA_MIN = 0.0;
    public final static double ALPHA_MAX = 1.0;

    private double _gamma;
    public final static double GAMMA_DEF = 0.0;
    public final static double GAMMA_MIN = 0.0;
    public final static double GAMMA_MAX = 1.0;

    /**
     * Constructor
     * @param name name of the obstacle
     * @param alpha braking rate
     * @param gamme wave braking
     */
    public DataObstacle(String name, double alpha, double gamma) 
    {
	setName(name);
	setAlpha(alpha);
	setGamma(gamma);
    }

    /**
     * Constructor filling fields with default values
     */
    public DataObstacle()
    {
	setName("");
	setAlpha(ALPHA_DEF);
	setGamma(GAMMA_DEF);
    }
    
    public boolean setName(String name)
    {
	_name = name;
	return true;
    }

    public String getName()
    {
	return _name;
    }

    public boolean setAlpha(double alpha)
    {
	boolean done = false;
	if(checkBounds(ALPHA_MIN, ALPHA_MAX, alpha)){
	    _alpha = alpha;
	    done = true;
	}else{
	    _alpha = ALPHA_DEF;
	}
	return done;
    }

    public double getAlpha()
    {
	return _alpha;
    }

    public boolean setGamma(double gamma)
    {
	boolean done = false;
	if(checkBounds(GAMMA_MIN, GAMMA_MAX, gamma)){
	    _gamma = gamma;
	    done = true;
	}else{
	    _gamma = GAMMA_DEF;
	}
	return done;
    }

    public double getGamma()
    {
	return _gamma;
    }

    public String toString()
    {
	return ("Obstacle : " + _name + 
		" alpha = " + _alpha + 
		" ; gamma = " + _gamma +"\n");
    }

}
